package org.example.httpproxy;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author 刁海文
 * @date 2022/5/3 18:49
 * @desc
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    public void initChannel(SocketChannel ch) {
        ch.pipeline().addLast(
                new LoggingHandler(LogLevel.DEBUG),
                new HttpRequestDecoder(),
                new HttpResponseEncoder(),
                new HttpObjectAggregator(1024 * 1024),
                new HttpProxyClientHandler());
    }
}
